<template>
	<uni-section title="详细信息" type="line">
		<view>
			<view>
				<!-- 基本信息（不可修改） -->
				<uni-forms ref="form" :model="form">
					<uni-row class="first">
						<uni-col :span="11" class="title">学号/工号</uni-col>
						<uni-col :span="11" class="content">{{form.studentId}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">姓名</uni-col>
						<uni-col :span="11" class="content">{{form.name}}</uni-col>
					</uni-row>
					<view class="divider" />
					<!-- <uni-row>
						<uni-col :span="11" class="title">电话</uni-col>
						<uni-col :span="11" class="content">{{form.phone}}</uni-col>
					</uni-row>
					<view class="divider" /> -->
					<!-- <uni-row>
						<uni-col :span="11" class="title">用户类型</uni-col>
						<uni-col :span="11" class="content" v-if="form.teacherName == null">教师</uni-col>
						<uni-col :span="11" class="content" v-else>学生</uni-col>
					</uni-row>
					<view class="divider" /> -->
					<uni-row>
						<uni-col :span="11" class="title">设备编号</uni-col>
						<uni-col :span="11" class="content">{{form.instrumentId}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">设备名称</uni-col>
						<uni-col :span="11" class="content">{{form.instrumentName}}</uni-col>
					</uni-row>
					<view class="divider" />
					<!-- 
					<uni-row>
						<uni-col :span="11" class="title">设备编号</uni-col>
						<uni-col :span="11" class="content">{{form.instrumentId}}</uni-col>
					</uni-row>
					<view class="divider" /> -->
					
					<!-- <uni-row>
						<uni-col :span="11" class="title">提交时间</uni-col>
						<uni-col :span="11" class="content">{{form.sbumitTime}}</uni-col>
					</uni-row> -->
					<!-- <view class="divider" /> -->
					<uni-row>
						<uni-col :span="11" class="title">存放地</uni-col>
						<uni-col :span="11" class="content">{{form.storageLocation}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">领用人姓名</uni-col>
						<uni-col :span="11" class="content">{{form.receiverName}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">领用人工号</uni-col>
						<uni-col :span="11" class="content">{{form.receiverId}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">开始时间</uni-col>
						<uni-col :span="11" class="content">{{form.appointmentStart}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">结束时间</uni-col>
						<uni-col :span="11" class="content">{{form.appointmentEnd}}</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">使用方向</uni-col>
						<uni-col :span="11" class="content" v-if="form.useDirection==0">科研</uni-col>
						<uni-col :span="11" class="content" v-if="form.useDirection==1">教学</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">首次使用</uni-col>
						<uni-col :span="11" class="content" v-if="form.firstUse==0">是</uni-col>
						<uni-col :span="11" class="content" v-if="form.firstUse==1">否</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">经费科目</uni-col>
						<uni-col :span="11" class="content" v-if="form.expenditureSubject==0">科研</uni-col>
						<uni-col :span="11" class="content" v-if="form.expenditureSubject==1">教学</uni-col>
					</uni-row>
					<view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">领用单位</uni-col>
						<uni-col :span="11" class="content">{{form.applicationDepartment}}</uni-col>
					</uni-row>
					
				<!-- 	<view class="divider" /> -->
					<!-- <view class="divider" />
					<uni-row>
						<uni-col :span="11" class="title">指导教师</uni-col>
						<uni-col :span="11" class="content">{{form.teacherName}}</uni-col>
					</uni-row> -->
					<!-- <view class="divider" /> -->
					<!-- <uni-row>
						<uni-col :span="11" class="title">审核状态</uni-col>
						<uni-col :span="11" class="content" v-if="form.teacherResult == 0">待教师审核</uni-col>
						<uni-col :span="11" class="content" v-else-if="form.teacherResult == 1">审核已通过</uni-col>
						<uni-col :span="11" class="content" v-else-if="form.teacherResult == 2">审核未通过</uni-col>
						<uni-col :span="11" class="content" v-else-if="form.note1 == 1">预约取消</uni-col>
						<uni-col :span="11" class="content" v-else></uni-col>
					</uni-row> -->
					<view class="divider last" />

				</uni-forms>
				<!-- 弹出层 -->
				<uni-popup ref="alertDialog" type="dialog">
					<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确定" content="确定取消预约?"
						@confirm="dialogConfirm" @close="dialogClose">
					</uni-popup-dialog>
				</uni-popup>
				<!-- 提示信息弹窗 -->
				<uni-popup ref="message" type="message">
					<uni-popup-message :type="msgType" :message="messageText" :duration="2000">
					</uni-popup-message>
				</uni-popup>

				<!-- 按钮 -->
				<!-- <view class="re-button">
					<button type="primary" size="mini" @click="submit(1)" v-show="buttonFlag==0">通过</button>
					<button type="warn" size="mini" @click="submit(2)" v-show="buttonFlag==0">不通过</button>
					<button type="" size="mini" @click="returnBack">返回</button>
				</view> -->

				<view class="re-button1" v-if="form.note1==0">
					<!-- <button type="primary" size="mini" @click="submit(1)">通过</button>
					<button type="warn" size="mini"lick="submit(2)">不通过</button> -->
					<button type="warn" size="mini" @click="dialogToggle('success')">预约取消</button>
				</view>
				<!-- <view class="re-button2" v-else>
					<button type="" size=""  @click="dialogToggle('success')">返回</button>
				</view> -->
				<view style="height: 28px;"></view>

			</view>
		</view>

	</uni-section>

</template>

<script>
	import {
		listAppointment,
		updateAppointment,
		getAppointment
	} from "@/api/module/shao/appointment.js";
	/* import "@riophae/vue-treeselect/dist/vue-treeselect.css" */
	export default {

		name: "Issues",
		data() {
			return {
				msgType: 'success',
				messageText: '这是一条成功提示',
				// 查询参数
				queryParams: {
					studentId: null,
					department: null,
					name: null,
					gender: null,
					phone: null,
					idCard: null,
					teacherName: null,
					teacherId: null,
					equipmentType: null,
					applicationDepartment: null,
					instrumentId: null,
					instrumentName: null,
					modelNumber: null,
					specification: null,
					unitPrice: null,
					classifyNumber: null,
					purchaseDate: null,
					receiverId: null,
					receiverName: null,
					manufacturers: null,
					storageDate: null,
					storageLocation: null,
					expenditureSubject: null,
					useDirection: null,
					firstUse: null,
					equipmentType:null,
					appointmentStart: null,
					appointmentEnd: null,
					sbumitTime: null,
					auditStatus: null,
					teacherResult: null,
					adminResult: null,
					teacherTime: null,
					adminTime: null,
					userId: null,
					deptId: null,
					createBy: null,
					createTime: null,
					updateBy: null,
					updateTime: null,
					remark: null,
					note1: null,
					note2: null,
					note3: null,
					note4: null,
					note5: null,
					note6: null,
					note7: null,
					note8: null,
					note9: null,
					note10: null
				},
				form: {},
				// 遮罩层
				loading: true,
				// 选中数组
				ids: [],
				// 显示搜索条件
				showSearch: false,
				// 总条数
				total: 0,
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				//控制按钮是否显示的标志
				// buttonFlag: 1
			};
		},

		created() {
			const id = this.$route.query.id;
			// console.log(id)
			if (id) {
				// 获取表详细信息
				// console.log(id);
				getAppointment(id).then(res => {
					this.form = res.data;
					// console.log(typeof(this.form.adminResult));
					// if (this.form.adminResult == 0) {
					// 	this.buttonFlag = 0;
					// }
					// console.log(this.buttonFlag);
					// console.log(this.form)
				});
				this.queryParams = this.form;
			}
		
		},

		methods: {
			
			
			//获取数据
			getList() {
				this.loading = true;
				listAppointment(this.queryParams).then(res => {
					this.tableData = res.rows;
					this.total = res.total;
					this.loading = false;
				});
			},
			//弹出框
			dialogToggle(type) {
				this.msgType = type
				this.$refs.alertDialog.open()
			},
			dialogClose() {
				console.log('点击关闭')
			},
			dialogConfirm() {
				this.form.note1 = 1;
				// this.form.auditStatus = 3;
				updateAppointment(this.form).then(response => {
					// this.$modal.msgSuccess("预约取消成功");
					this.open = false;
					this.getList();
				});
				// 	console.log('点击确认')
				this.messageText = `预约取消成功`
				this.$refs.message.open()
				setTimeout(function() {
					uni.navigateTo({
						url: `/pages/module/shao/xiangxi`
					})
				}, 700);
			
			
			
			},
			//返回
			// returnBack() {
			// 	this.$tab.navigateTo('/pages/module/whd/index');
			// },

			//提交
			submit(flag) {
				/* this.form.auditStatus = flag; */
				this.form.teacherResult = flag;
				updateAppointment(this.form).then(response => {
					this.$modal.msgSuccess("审核成功");
					this.open = false;
				});
				this.returnBack();
			},
		},

	};
</script>

<style>
	.re-button1 {
		text-align: center;

	}

	.re-button2 {
		margin-left: 3%;
		margin-right: 3%;

	}

	.first {
		margin-top: 3%;
	}

	.title {
		/* display: block; */
		font-weight: bold;
		margin-left: 5%;
		text-align: left;
	}

	.content {
		/* display: block; */
		text-align: right;
		/* margin-left: 60%; */
		/* margin-right: 5%; */
		/* margin-top: -5%; */
	}

	.divider {
		margin-top: 3%;
		margin-bottom: 3%;
		margin-right: 2%;
		margin-left: 2%;
		background: #E0E3DA;
		width: 96%;
		height: 1rpx;
	}

	.divider.last {
		margin-bottom: 8%;
	}
</style>
